<?php 
ob_start(); session_start();
require_once('config/setting.php');
if (!$_SESSION['userid'])
{
	header('location: login.php');
	
}
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
	<title>The Century - Admin Panel</title>
	<style>
        .topmenu{
            font-family:arial;
			font-weight:bold;
            font-size:16px;
            color:#FFFFFF;
            text-decoration:none;
        }
        .topmenu:hover{
            font-family:arial;
			font-weight:bold;
            font-size:16px;
            color:#FFFFFF;
            text-decoration:underline;
        }
    </style>
</head>
<body>
<table width="100%">
<div style="padding:10px; font-size:20px; font-family:verdana;"><span>THE CENTURY <span style="font-size:14px">Admin Panel</span></span></div>

<tr>
	<td style="width:100%; height:auto; ">
	  <table  style="width:100%; height:100%" border="0">
		<tr>
			<td style="background:#FF0000; height:71px;">
			   <div align="center">	
				   <table style="width:960px;" cellpadding="0" cellspacing="0" border="0">
						<tr>
							<td style="height:42px; padding-top:15px"  >
								<table align="center" cellpadding="0" cellspacing="0" border="0">
									<tr>
										<td style="font-weight:bold; color:#FFFFFF">
                                        	<a href="view-customers.php" class="topmenu">View Customers</a> &nbsp;|&nbsp; 
											<a href="reports.php" class="topmenu">Reports</a> &nbsp;|&nbsp; 
                                            <a href="reservation.php" class="topmenu">Reservation</a> &nbsp;|&nbsp; 
                                            <a href="slots.php" class="topmenu">Slots</a> &nbsp;|&nbsp;  
                                            <a href="question.php" class="topmenu">Question</a> &nbsp;|&nbsp;  
                                            <a href="menus.php" class="topmenu">Menus</a> &nbsp;|&nbsp;  
                                            <a href="logout.php" class="topmenu">Logout</a> 
                                        </td>
									</tr>
								</table>							
                             </td>
						</tr>
					</table>			
				</div>			
              </td>
		</tr>	
	</table></td>
</tr>
<!--content-->
<tr>
	<td style="width:800px; background:url(../images/w_bgr.jpg); height:500px;" valign="top" align="center">
        <table  style="width:800px; border:solid 1px  #999999; font-family:arial; font-size:12px" >
        	<tr>
            	<td bgcolor="#999999" style="color:#FFF" height="30px" align="center" >Reservation Date</td>
               	<td bgcolor="#999999" style="color:#FFF" height="30px" align="center">Selected Table</td>
               	<td bgcolor="#999999" style="color:#FFF" height="30px" align="center">Selected Time</td>
               	<td bgcolor="#999999" style="color:#FFF" height="30px" align="center">Status</td>
            </tr>
			<?php
					function convertimedate($ndate,$ntime){
						$breakdate = explode('/',$ndate);
						$nmonth = $breakdate[0];
						$nday = $breakdate[1];
						$nyear = $breakdate[2];
						switch ($ntime) {
							case '11:00AM':$nhour = 11; break;
							case '1:00PM': $nhour = 13; break;
							case '3:00PM': $nhour = 15; break;
							case '5:00PM': $nhour = 17; break;
							case '7:00PM': $nhour = 19; break;
						}
						$ntimestamp = mktime($nhour, 0, 0, $nmonth, $nday, $nyear);
						return $ntimestamp;
					}
					
					$result = mysql_query("select * from tbl_reservation order by id DESC ") or die (mysql_error());
					while ($row = mysql_fetch_array($result)){
						$id = $row['id']; 
						$mid = $row['mid']; 
						$selected_date = $row['selected_date']; 
						$selected_table = $row['selected_table']; 
						$selected_time = $row['selected_time']; 
						$status = $row['status'];
						if($status=='0'){
							$statdesc = 'Cancelled';	
						}
						if($status=='1'){
							$statdesc = 'Unconfirmed';	
						}
						if($status=='2'){
							$statdesc = 'Confirmed';	
						}
						
						if(time()>convertimedate($selected_date,$selected_time)){
							if($status=='2'){
							  $statdesc = 'Completed';
							}
							if($status=='1'){
							  $statdesc = 'Cancelled';	
							}
						}
						
						
						echo '
							<tr >
								<td align="center" height="24px" style="border-bottom:dotted #666666 1px;">'.$selected_date.' </td>
								<td align="center" style="border-bottom:dotted #666666 1px;">Table '.$selected_table.'</td>
								<td align="center" style="border-bottom:dotted #666666 1px;">'.$selected_time.'</td>
								<td align="center" style="border-bottom:dotted #666666 1px;"><a href="confirm.php?rid='.$id.'">'.$statdesc.'</a></td>
							</tr>';
					}                
                ?>                        
        </table>
     </td>
</tr>
<!--footer-->
<tr>
	<td style="width:100%;"><table style="width:100%; height:100%">
		<tr>
			<td style="width:50%;"><img alt="" src="../images/spacer.gif" width="1" height="1"></td>
			<td style="width:766px;"><table style="width:766px;">
				<tr><td class="end"><table>
					
				</table></td></tr>
				<tr>
				  <td class="end">&nbsp;</td>
			  </tr>
			</table></td>
			<td style="width:50%;"><img alt="" src="../images/spacer.gif" width="1" height="1"></td>
		</tr>
	</table></td>
</tr>
</table>
</body>
</html>
